<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<% String basepath = request.getContextPath(); %>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="<%=basepath%>/css/nomal.css" rel="stylesheet" type="text/css" />
		<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/validatorTool.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/utilTool.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/calendar/WdatePicker.js"></script>
		<script language="JavaScript" type="text/javascript" src="<%=basepath%>/js/caltimer.js"></script>
		
		<link type="text/css" rel="stylesheet" href="<%=basepath%>/newcalendar/calendar.css" />
		<script language="javascript" type="text/javascript" src="<%=basepath%>/newcalendar/calendar.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/newcalendar/calendar-zh.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/newcalendar/calendar-setup.js"></script>
<style type="text/css">
.mycolor {
	color: #FF0000;
}
</style>
<script type="text/javascript">
		
	jQuery(document).ready(
		function(){
			//供应商类型
			initselect("suptype",'${currentInfo.suptype}');
			//企业性质
			//initselect("entproperty",'${currentInfo.entproperty}');
			//初始化两个字段：经济类型
			initmodel("ectypename","${currentInfo.ectype}");
		}
	)
	
	//初始化参考数据的名称
	function initmodel(name,pk){
		jQuery.ajax({
				type: "GET", 
	            async:false,
	            url:"<%=basepath%>/register/initmodel?pk="+pk, 
	            dataType:"text", 
	            success:function(result){   
	                if(result !=''){
	                	var items = result.split("|");
	                	var nameitem = name.split(",");
	                	for(var i=0;i<nameitem.length;i++){
	                		if(i<items.length){
	                			document.getElementById(nameitem[i]).value = items[i];
	                		}
	                	}
	                }
	            } 
	        }
		)
	}
	//这里进行提交
	function nextStep() {
		var ErrMsg = checkField();
		if(trim(ErrMsg)!=""){
			alert(ErrMsg);
			return;
		}
		if(isValidBuildDate(document.getElementById("builddate")) && subReduNumRegFund(document.getElementById("regfound"),2,13)){
			document.forms[0].action = "<%=basepath %>/register/nopassEditNextStep?nextStep=2";
			document.forms[0].submit();
		}
	}
	
	function initList(id,code){
		var url = "iframe:<%=basepath%>/register/initlist?id="+id+"&code="+code;
		dialog("", url,"500", "400", "","");
	}
	
	//初始化供应商分类
	function initSupClsList(id){
		var url = "iframe:<%=basepath%>/selfinfo/initSupClsList?id="+id+"";
		dialog("", url,"500", "400", "","");
	}
	
	//初始化上级供应商
	function initSupList(id){
		var url = "iframe:<%=basepath%>/selfinfo/initSupList?id="+id+"";
		dialog("", url,"500", "400", "","");
	}
	
	function backurl(){
		var src=${src};
		var url = "<%=basepath%>/register/suppNotCheckPass";
		if(src==1){
			url="<%=basepath%>/register/suppnoPass";
		}
		location.href = url;
	}
	
	//必输项校验
	function checkField(){
		    var supnameval = document.getElementById("supname").value;
			var taxpayeridval = document.getElementById("taxpayerid").value;
			var legalbodyval = document.getElementById("legalbody").value;
			var salelicencenoval = document.getElementById("salelicenceno").value;
			var builddateval = document.getElementById("builddate").value;
			var regfoundval = document.getElementById("regfound").value;
			var ectypenameval = document.getElementById("ectypename").value;
			var ErrMsg = "";
			
			if(supnameval == null ||trim(supnameval)==""){
				ErrMsg += "供应商全称不允许为空!";
			}
			if(taxpayeridval == null || trim(taxpayeridval)==""){
				ErrMsg += "\n纳税人登记号不允许为空!";
			}
			if(legalbodyval == null || trim(legalbodyval)==""){
				ErrMsg += "\n法人不允许为空!";
			}
			if(salelicencenoval == null || trim(salelicencenoval)==""){
				ErrMsg += "\n营业执照号不允许为空!";
			}
			if(builddateval == null || trim(builddateval)==""){
				ErrMsg += "\n成立日期不允许为空!";
			}
			if(regfoundval == null || trim(regfoundval)==""){
				ErrMsg += "\n注册资本不允许为空!";
			}
			if(ectypenameval == null || trim(ectypenameval)==""){
				ErrMsg += "\n经济类型不允许为空!";
			}
			var bool = isNum(regfoundval);
			if(bool == false){
			   	alert("\n注册资本不合法!");
			   	return;
			}
			return ErrMsg;
	}
	
	function trim(strToTrim) { 
	     result=strToTrim 
	     for (_i=0; _i<strToTrim.length; _i++) { 
	            if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(_i+1) 
	            else _i=strToTrim.length 
	     } 
	     strToTrim=result 
	     for (_i=strToTrim.length-1; _i>=0; _i--) { 
	            if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(0,_i) 
	            else _i=0 
	      } 
       return result 
	} 
	
	function isValidBuildDate(obj){
		if(!isEmpty(obj.value) && !isDate(obj.value)){
			jQuery("#message").html("请重新输入YYYY-MM-DD格式日期");
			obj.focus();
			return false;
		}else{
			jQuery("#message").html("");
			return true;
		}
	}
</script>
</head>
	<body class="fullbody">
		<div id="content" class="content">
			<div class="">
				<b class="rtop"><b class="r1"></b><b class="r2"></b>
				<b class="r3"></b><b class="r4"> </b> </b>
					<table cellpadding="0" cellspacing="0" border="0" width="980">
						<tr>
							<td class="leftmargin"></td>
							<td valign="top" align="center">
								<form method="post">
									<input type="hidden" name="src" value="${src}"/>
									<table cellpadding="0" cellspacing="0" border="0" width="830">
										<tr class="title">
											<td colspan="4"> </td>
										</tr>
										<tr class="inputrow">
											<td class="w1" >供应商全称：</td>
											<td class="w5" style="width:380px">
												<input type="hidden" name="pk_supinfocheck_h"
													value="${currentInfo.pk_supinfocheck_h}" />
												<input type="text" name="supname" class="textstyle"
													value="${currentInfo.supname}" />
												<span class="needfill">*</span>
												<font class="memoFont">（与营业执照一致）</font>
											</td>
											<td class="w1">英文全称：</td>
											<td class="w5">
												<input type="text" name="supenname" class="textstyle"
													value="${currentInfo.supenname}" />
												<input type="hidden" name="suptype"  value="1"/>
												<input type="hidden" name="supCate" 
													value="${currentInfo.supCate}" class="textstyle" readOnly />
												<input type="hidden" name="parentSup"
													value="${currentInfo.parentSup}" class="textstyle" readOnly/>
												<input type="hidden" name="supRankStatus" 
													value="${currentInfo.supRankStatus}" class="textstyle" readOnly />
											</td>
										</tr>
										<tr class="inputrow">
											<td class="w1">供应商类型：</td>
											<td class="w5">
												<select name="suptype" id="suptype" class="textstyle"  >
													<option value="0" selected="selected">外部单位</option>
													<option value="1">内部单位</option>
												</select>
											</td>
											<td class="inputrow">银行资信等级：</td>
												<td class="w5">
													<select name="bankcreditrank" id="bankcreditrank" class="textstyle" >
														<option ></option>
														<option value="3"
														<c:if test="${currentInfo.bankcreditrank == '3'}">{
															selected
														}												
														</c:if>>3A</option>
														<option value="2"
														<c:if test="${currentInfo.bankcreditrank == '2'}">{
															selected
														}												
														</c:if>>2A</option>
														<option value="1"
														<c:if test="${currentInfo.bankcreditrank == '1'}">{
															selected
														}												
														</c:if>>A</option>
													</select>
												</td>
											</tr>
											<tr class="inputrow">
												<td class="w1">经济类型：</td>
												<td class="w5">
													<input type="text" name="ectypename" id="ectypename"
														 class="textstyle" onclick="initList('ectype','SYS004_0xx')" readOnly/> 
													<span class="needfill">*</span>
													<input type="hidden" name="ectype" id="ectype"
														value="${currentInfo.ectype}" class="textstyle"  readOnly/>
												</td>
												<td class="w1">纳税人登记号：</td>
												<td class="w5">
													<input type="text" name="taxpayerid"
														value="${currentInfo.taxpayerid}" class="textstyle" />
													<span class="needfill">*</span>
												</td>
											</tr>
											<tr class="inputrow">
												<td class="w1">法人：</td>
												<td class="w5">
													<input type="text" name="legalbody"
														value="${currentInfo.legalbody}" class="textstyle" />
													<span class="needfill">*</span>
												</td>
												<td class="w1">营业执照号：</td>
												<td class="w5">
													<input type="text" name="salelicenceno"
															value="${currentInfo.salelicenceno}" class="textstyle" />
													<span class="needfill">*</span>
												</td>
											</tr>
										<tr class="inputrow">
											
											<td class="w1">成立日期：</td>
											<td class="w5">
												<input type="text"  name="builddate"
													value="${currentInfo.builddate}" id="builddate" 
													onchange="isValidBuildDate(this);" 
													class="textstyle" />
												<input type="image" src="<%=basepath%>/images/common/cal.jpg" onclick="return showCalendar('builddate', 'y-mm-dd');"/>
												<span class="needfill">*</span>
											</td>
											<td class="w1">注册资本：</td>
											<td class="w5">
												<input type="text" name="regfound"
													value="${currentInfo.regfound}" class="textstyle" onChange="subReduNumRegFund(this,2,13)"/>
												<span class="needfill">*</span>
											</td>
										</tr>
										<tr>
											<td colspan="4">&nbsp;</td>
										</tr>
										<tr class="buttonrow">
											<td align="right" colspan="4">
												<input type="button" value="返回" onclick="backurl();" class="btnscs" /> 
							 					&nbsp;&nbsp;
												<input type="button" value="下一步" onclick="nextStep();" class="btnscs" />
											</td>
										</tr>
									</table>
								</form>
							</td>
						</tr>
					</table>
				<div id="message" class="mycolor" >
					<c:out value="${ERROR_MESSAGE}"></c:out>
				</div>
				<b class="rbottom">
					<b class="r4"></b>
					<b class="r3"></b>
					<b class="r2"></b>
					<b class="r1"> </b> 
				</b>
			</div>
		</div>
	</body>